package cn.cqautotest.micalendar;

import android.os.Build;
import android.os.Bundle;
import android.widget.Button;

import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AppCompatActivity;

@RequiresApi(api = Build.VERSION_CODES.P)
public class MainActivity extends AppCompatActivity {

    private static final String TAG = MainActivity.class.getSimpleName();
    private Button mBtnInsertEvent;
    private String calendarId = "1";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        findView();
        initEvents();
        requestPermission();
    }

    private void initEvents() {
        mBtnInsertEvent.setOnClickListener(v -> {
           // boolean hasCalendarPermission = hasCalendarPermission();
           // if (!hasCalendarPermission) {
           //     requestPermission();
           //     return;
           // }
           // Calendar startCalendar = Calendar.getInstance();
           // Calendar endCalendar = Calendar.getInstance();
           // startCalendar.set(2021, 0, 3, 16, 33);
           // endCalendar.set(2021, 0, 3, 16, 35);
           // CalendarEventUtils.insertEvent(startCalendar, endCalendar, "玩游戏", "到了玩游戏的时间啦！");
        });
    }

    private void findView() {
        mBtnInsertEvent = findViewById(R.id.btnInsertEvent);
    }

    private void requestPermission() {
        // XXPermissions.with(this).permission(Permission.Group.CALENDAR).request(this);
    }

    // private boolean hasCalendarPermission() {
    //     return XXPermissions.isHasPermission(this, Permission.Group.CALENDAR);
    // }

    // @Override
    // public void hasPermission(List<String> granted, boolean isAll) {
    //
    // }

    // @Override
    // public void noPermission(List<String> denied, boolean quick) {
    //
    // }
}